<?php


namespace app\model\partner;


use app\model\config\RegionModel;
use think\Model;
use think\model\concern\SoftDelete;

class EscortMenuModel extends Model
{
    protected $name = 'escort_menu';
    protected $autoWriteTimestamp = true;

    use SoftDelete;
    protected $defaultSoftDelete = 0;

    protected $json = ['city_id'];
    protected $jsonAssoc = true;

    protected $append = ['city_txt'];


    public function getCityTxtAttr($value, $data)
    {
        if (!isset($data['city_id'])) {
            return '';
        }
        $cityArr = RegionModel::whereIn('id', $data['city_id'])->column('name');
        return implode(',', $cityArr);
    }

    public function getDetailAttr($value, $data)
    {
        if (!$value) {
            return '';
        }
        return $value;
    }
}